/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sigl.utils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import org.ho.yaml.Yaml;

/**
 *
 * @author uxmal
 */
public class JAML {

    public static Object load (File file)
            throws java.io.FileNotFoundException {
        // yaml = new File(filename);
        return Yaml.load(file);
    }
    public static Object load(String filename)
                throws java.io.FileNotFoundException {
        // yaml = new File(filename);
        return Yaml.load(filename);

    }

    public static void streamdump (String filename, Object data) {
           
        PrintWriter writer = null;
        try {
            writer = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
            writer.close();
        } catch (java.io.IOException exc) {
            System.out.println("Erreur lors du dump.");
        }
    }
    
    public static void dump (File file, Object data)
            throws java.io.FileNotFoundException {
        Yaml.dump(data, file, true);
    }
    // private void writeMap (string)
    public static void dump (String filename, Object data)
            throws java.io.FileNotFoundException {
        File yaml = new File(filename);
        Yaml.dump(data, yaml, true);
    }

}
